<template>
  <!--授权信息  -->
  <div style="height:820px">
    <FormPanel
      ref="infoPower"
      :list="initForm"
      :cols="3"
      :formType="value.type"
      :labelWidth="140"
      :isSubmitBtn="false"
      @formChange="formChangeHandle"
    />
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
export default {
  mixins: [dictionary],
  props: {
    value: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      initForm: this.initFormFun(),
      formValue: {}
    };
  },
  mounted() {
    console.log(this.value); //获取到行id 、类型（新增、详情）
    //请求接口进行赋值，自己写吧
  },
  methods: {
    //初始化数据
    init(data) {
      this.formValue = {};
      if (data.type === 'edit') {
        this.initForm.forEach(x => {
          x.initialValue = data.row[x.fieldName];
        });
      }
    },
    //搜索数据
    initFormFun() {
      return [
        {
          type: 'DATE',
          label: '授权时间',
          fieldName: 'field1',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '',
          placeholder: '请选择',
          style: { width: '100%' },
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'DATE',
          label: '验收通过时间',
          fieldName: 'field2',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '',
          placeholder: '请选择',
          style: { width: '100%' },
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'DATE',
          label: '入网通过时间',
          fieldName: 'field3',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '2019-08-19',
          placeholder: '请选择',
          style: { width: '100%' },
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'SELECT',
          label: '销售店面级别',
          fieldName: 'field4',
          placeholder: '请选择',
          initialValue: '',
          itemList: this.createDictList('1008'),
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'INPUT',
          label: '销售邮箱',
          fieldName: 'field5',
          initialValue: '',
          placeholder: '请输入',
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'INPUT',
          label: '销售热线',
          fieldName: 'field6',
          initialValue: '',
          placeholder: '请输入',
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'INPUT',
          label: '展示面积',
          fieldName: 'field7',
          initialValue: '',
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '办公面积',
          fieldName: 'field8',
          initialValue: '',
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '展厅面宽',
          fieldName: 'field9',
          initialValue: '',
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '销售店经度',
          fieldName: 'field10',
          initialValue: '',
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '销售店纬度',
          fieldName: 'field11',
          initialValue: '',
          placeholder: '请输入'
        },
        {
          type: 'TEXT_AREA',
          label: '销售运营地址',
          fieldName: 'field12',
          rows: 2,
          initialValue: '',
          placeholder: '请输入',
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'blur'
            }
          ]
        },
        {
          type: 'INPUT',
          label: '工位数量',
          fieldName: 'field13',
          initialValue: '',
          placeholder: '请输入'
        },
        {
          type: 'SELECT',
          label: '售后店面级别',
          fieldName: 'field14',
          placeholder: '请选择',
          initialValue: '',
          itemList: this.createDictList('1008'),
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'INPUT',
          label: '工时系数',
          fieldName: 'field15',
          initialValue: '',
          placeholder: '请输入',
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'blur'
            }
          ]
        },
        {
          type: 'SELECT',
          label: '样板店&电池联合服务中心',
          fieldName: 'field16',
          placeholder: '请选择',
          initialValue: '',
          itemList: this.createDictList('1008'),
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'SELECT',
          label: '动力电池回收网络',
          fieldName: 'field17',
          placeholder: '请选择',
          initialValue: '',
          itemList: this.createDictList('1008'),
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'INPUT',
          label: '电池联合服务站',
          fieldName: 'field18',
          initialValue: '',
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '售后服务热线',
          fieldName: 'field19',
          initialValue: '',
          placeholder: '请输入',
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'INPUT',
          label: '售后邮箱',
          fieldName: 'field20',
          initialValue: '',
          placeholder: '请输入',
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'INPUT',
          label: '前台座机',
          fieldName: 'field21',
          initialValue: '',
          placeholder: '请输入',
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'INPUT',
          label: '24小时服务电话',
          fieldName: 'field22',
          initialValue: '',
          placeholder: '请输入',
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'INPUT',
          label: '道路运输经营许可证',
          fieldName: 'field23',
          initialValue: '',
          placeholder: '请输入',
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'INPUT',
          label: '与销售店的距离',
          fieldName: 'field25',
          initialValue: '',
          placeholder: '请输入',
          unitRender: () => {
            return <span>(M)</span>;
          },
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'INPUT',
          label: '售后店经度',
          fieldName: 'field26',
          initialValue: '',
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '售后店纬度',
          fieldName: 'field27',
          initialValue: '',
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '车间面积',
          fieldName: 'field28',
          initialValue: '',
          placeholder: '请输入'
        },
        {
          type: 'TEXT_AREA',
          label: '售后运营地址',
          fieldName: 'field29',
          rows: 2,
          initialValue: '',
          placeholder: '请输入',
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'blur'
            }
          ]
        },
        {
          type: 'UPLOAD_IMG',
          label: '许可证附件',
          fieldName: 'field24',
          upload: {
            actionUrl: '', //上传的地址
            fixedSize: [300, 500], //剪裁尺寸
            isCalcHeight: false,
            limit: 1 //上传数量
          },
          initialValue: '', 
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        }
      ];
    },
    formChangeHandle(val) {
      this.formValue = val;
    }
  }
};
</script>